﻿@model PagedList.IPagedList<CP_SchoolForChildren_v0._1.Models.RelatedModel.SeachSchoolModel>
<style type="text/css">
    #search-suggestion p{
        margin: 5px;
    }
    #search-suggestion label.sslabel
    {
        line-height: 30px;
        margin-left: 5px;
        padding: 5px;
        vertical-align: middle;
                    
    }
    #search-suggestion #suggest-search
    {
        margin-left: 80px;
        margin-top: 15px;
    }
    label.sslabel .userQuality
    {
        vertical-align: middle;
        padding: 5px;
        margin: 5px;
        cursor: pointer;
    }
</style>
<script type="text/javascript">
    function boxStatus(id) {
        if ($("#sbox"+id).text() == "Ẩn"){
            $("#sbox" + id + "-" + id).hide(500);
            $("#sbox" + id).text("Hiện");
        } else {
            $("#sbox" + id + "-" + id).show(500);
            $("#sbox" + id).text("Ẩn");
        }
        
    }
</script>
<div class="dashboard" style="width: 305px;">
    <div class="content-header">
        <div class="header-inner">
            <div class="rightTxt1" id="search_02" style="position: relative; margin-bottom: 5px;">
                    <form method="GET" id="search-form" action="@Url.Action("SearchByName", "School")" data-ajax-update="#search-result" data-ajax-loading="#spinner"  data-ajax-mode="replace" data-ajax-method="get" data-ajax="true">
                        <input type="text" value="@ViewBag.schoolName" name="schoolName" id="schoolName" placeholder="Nhập từ khóa để tìm kiếm" style="width: 200px;"/>            
                        <input type="submit" id="searchSubmit" value="Tìm kiếm" style="margin-left:5px" />
                    </form>
                    <br class="spacer"/>
            </div>
            <br class="spacer"/>
            <div class="rightTxt1" id="search_01" style="position: relative;  border-bottom: 1px dotted #774F38; margin-bottom: 10px;border-top: 1px dotted #774F38;">
                <form id="condition-form" action="@Url.Action("SearchConditionResult", "School")" method="GET" style="padding: 10px;" data-ajax-update="#search-result" data-ajax-loading="#spinner" data-ajax-mode="replace" data-ajax-method="get" data-ajax="true">
                    <div>
                        <h2>Tiêu chí</h2>
                        <div style="float: right; width: 10%">
                            <a id="sbox2" onclick="boxStatus(2)" style="cursor: pointer">Ẩn</a>
                        </div>
                        <br class="spacer"/>
                    </div>
                    <div id="sbox2-2">
                    <select id="CityID" name="CityID">
                        <option value="0">-- Tất cả thành phố --</option>
                    </select>
                    <select id="DistrictID" name="DistrictID" style="display: none;">
                        <option value="0">-- Tất cả Quận Huyện --</option>
                    </select>
                    <select id="SchoolTypeID" name="SchoolTypeID">
                        <option value="0">-- Tất cả loại trường --</option>
                    </select>
                    <select id="Fee" name="Fee">
                        <option value="1">-- Tất Cả Mức Học Phí (VNĐ) --</option>
                        <option value="2">Dưới 1.000.000</option>
                        <option value="3">1.000.000-2.000.000</option>
                        <option value="4">2.000.000-3.000.000</option>
                        <option value="5">3.000.000-4.000.000</option>
                        <option value="6">4.000.000-5.000.000</option>
                        <option value="7">Trên 5.000.000</option>
                    </select>
                
                    <div id="ListService" name="ListService">
                    
                    </div>
                    <input type="submit" value="Tìm Kiếm" id="search1" style="margin-left: 100px;"/>
                    </div>
                </form>
            </div>
            <div id="search_03" style="position: relative; padding: 15px">
                <form id="search-suggestion" method="get" action="@Url.Action("SchoolSugesstion", "Suggestion")" data-ajax-update="#search-result" data-ajax-loading="#spinner" data-ajax-mode="replace" data-ajax-method="GET" data-ajax="true">
                    <div>
                        <h2>Gợi ý</h2>
                        <div style="float: right; width: 10%">
                            <a id="sbox3" onclick="boxStatus(3)"style="cursor: pointer">Ẩn</a>
                        </div>
                        <br class="spacer"/>
                    </div>
                    <div id="sbox3-3">

                    <p style="font-weight: bold; clear:both; margin-left: 8px">Mức học phí mong muốn</p>
                    <p><span style="font-style: inherit; color: red; font-weight: normal;margin-left: 8px">(đơn vị - triệu đồng)</span> </p>
                    <input id="userEducation" type="text" value="@ViewBag.userEducation" name="userEducation">
                    <span class="error" style="display: none"></span>
                    <br class="clear"/>
                    <p style="padding-bottom: 5px; font-weight: bold; clear:both">Chất lượng trường học mong muốn</p>
                    <label class="sslabel">
                        <input class="userQuality" type="radio" checked="checked" id="userQuality" name="userQuality" value="1" />Bình thường
                    </label>
                    <br class="clear"/>
                    <label class="sslabel">
                        <input class="userQuality" type="radio" name="userQuality" value="2"><label>Cao</label>
                    </label>
                    <br class="clear"/>
                    <label class="sslabel">
                        <input class="userQuality" type="radio" name="userQuality" value="3"><label>Rất Cao</label>
                    </label>
                    <br class="clearfix">
                    <input type="submit" value="Tìm kiếm" class="modibutton" id="suggest-search" style="margin-left: 100px;"/>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
 <script type="text/javascript">
     $(document).ready(function () {
         var cboCity = $(document).find('select[name="CityID"]');
         var divListService = $(document).find('div[name="ListService"]');
         var cboType = $(document).find('select[name="SchoolTypeID"]');
         var cboLine = $(document).find('select[name="DistrictID"]');
         cboCity.ready(function (e) {
             console.log('ready');
             var cid = cboCity.val();
             // Load district Combo by cityID
             var url2 = '@Url.Action("GetCityOptionsByGet", "Function")';
             $.getJSON(url2, { ajax: 'true' }, function (response) {
                 var result = response.Result;
                 var options = '<option value="0">-- Tất cả thành phố --</option>';
                 cboCity.html(options);
                 if (result == 'OK') {
                     var rows = response.Options;
                     for (var k = 0; k < rows.length; k++) {
                         options += '<option value="' + rows[k].Value + '">' +
                             rows[k].DisplayText + '</option>';
                     }
                 }
                 cboCity.html(options);
             });
         });

         cboType.ready(function (e) {
             var cid = cboCity.val();
             // Load district Combo by cityID
             var url2 = '@Url.Action("GetSchoolTypeOptionsByGet", "Function")';
             $.getJSON(url2, { ajax: 'true' }, function (response) {
                 var result = response.Result;
                 var options = '<option value="0">-- Tất cả loại trường --</option>';
                 cboType.html(options);
                 if (result == 'OK') {
                     var rows = response.Options;
                     for (var k = 0; k < rows.length; k++) {
                         options += '<option value="' + rows[k].Value + '">' +
                             rows[k].DisplayText + '</option>';
                     }
                 }
                 cboType.html(options);
             });
         });

         divListService.ready(function (e) {
             var cid = cboCity.val();
             // Load district Combo by cityID
             var url2 = '@Url.Action("GetServiceCheckListByGet", "Function")';
             $.getJSON(url2, { ajax: 'true' }, function (response) {
                 var result = response.Result;
                 var options = '';
                 if (result == 'OK') {
                     var rows = response.Options;
                     for (var k = 0; k < rows.length; k++) {
                         options += '<div><input type="checkbox" id="ServiceID" name="ServiceID" value="' + rows[k].Value + '">    ' +
                             rows[k].DisplayText + "</div>";
                     }
                 }
                 divListService.html(options);
             });
         });


         // City ComboBox Change
         cboCity.change(function (e) {
             var cid = $(this).val();
             if (cid == 0) {
                 cboLine.hide();
                 return;
             }
             // Refresh District Combo
             var url = '@Url.Action("GetDistrictOptions", "Function")' + '?cityId=' + cid;
             $.getJSON(url, { ajax: 'true' }, function (response) {
                 var result = response.Result;
                 var options = '<option value="0">-- Tất cả quận huyện --</option>';

                 cboLine.html(options);
                 if (result == 'OK') {
                     var rows = response.Options;
                     for (var i = 0; i < rows.length; i++) {
                         options += '<option value="' + rows[i].Value + '">' +
                             rows[i].DisplayText + '</option>';
                     }
                 }
                 cboLine.html(options);
                 cboLine.show();
                 cboLine.change();
             });


         });
         cboCity.val(2);
     });
 </script>